<?php
/**
 * Created by PhpStorm.
 * User: DELL
 * Date: 2018/7/12
 * Time: 19:43
 */
namespace app\api\controller;
use app\common\lib\Aes;
use app\common\lib\exception\ApiException;
use think\Controller;

class Test extends Common
{
    public function test()
    {
        $data = [
            'usernmae'  => '勒布朗',
            'age'       => 34,
            'sex'       => '男',
            'team'      =>[
                'first' =>'热火',
                'second'=>'骑士',
                'three' =>'湖人'
            ]
        ];

        return show(1,'success',$data,201);
    }

    public function test1()
    {
        if($data)
        {
            echo 1;exit;
        }
    }

    public function test2()
    {
        $a = 1;
        if($a > 0)
        {
            return show(0,'fail');
        }
    }

    public function test3()
    {
        $a = 1;
        /*if($a =1)
        {
            //当使用TP内置的异常返回信息的同时,我们还要根据不同的场景返回不同的httpCode,这时我们就要自定义一个异常类
            exception('什么连');
        }*/
        if($a = 1)
        {
            throw new ApiException('什么鬼啊',400);
        }
    }

    /*function random($num='16')
    {
        $a = range(0,9);
        for($i=0;$i<$num;$i++){
            $b[] = array_rand($a);
        }
        return join("",$b);
    }*/

    /**
     * header()里面包含的东西并不包含你地址栏url输入的参数
     */
    public function test4()
    {
        $h = request()->header();
        dump($h);
    }

}